package com.karolak.ws;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;

//import com.karolak.entity.Person;

@WebService(endpointInterface = "com.karolak.ws.EntityWebServiceSEI", serviceName = "EntityWebService")
public class EntityWebService implements EntityWebServiceSEI {

	@Resource
	private WebServiceContext context;

	@PostConstruct
	public void init() {

	}

	@PreDestroy
	public void teardown() {

	}

	@WebMethod
	public Person find(Integer id) {

		Person person = new Person();
		person.setId(id);
		person.setFirstName(String.format("firstName-%s", id));
		person.setLastName(String.format("lastName-%s", id));
		return person;
	}

	@WebMethod
	public List<Person> select(HashMap<String, String> params) {
		List<Person> list = new ArrayList<Person>();
		Person person = new Person();
		person.setId(1);
		person.setFirstName(String.format("firstName-%s", 1));
		person.setLastName(String.format("lastName-%s", 1));
		Person person2 = new Person();
		person2.setId(2);
		person2.setFirstName(String.format("firstName-%s", 2));
		person2.setLastName(String.format("lastName-%s", 2));
		list.add(person);
		list.add(person2);
		return list;
	}

	public String findPerson(Integer id) {
		// TODO Auto-generated method stub
		return "Hello Person: " + id + " at " + new Date() + ".";
	}

	public WebServiceContext getContext() {
		return context;
	}

	public void setContext(WebServiceContext context) {
		this.context = context;
	}
}
